% note: aafRawData is a matrix with 2 columns. The first is the
% event type(1, 2 ,3 ,4 ,5), the second is the timestamp in milliseconds (the zero here is
% when the mote was powered)
%
function ComputeFeatures( tEvent )
	%
	% timestamps of some important events
	if( numel(tEvent.aaiDoorOpeningClosingTransitions) > 0 )
		%
		fFirstDoorOpenTime		= tEvent.aaiDoorOpeningClosingTransitions(1, 1);
		fFirstDoorCloseTime		= tEvent.aaiDoorOpeningClosingTransitions(1, 2);
		%
	else%
		%
		fFirstDoorOpenTime		= 0;
		fFirstDoorCloseTime		= 0;
		%
	end;%
	if( numel(tEvent.aaiLaser1OpeningClosingTransitions) > 0 )
		%
		fFirstLaser1OpenTime	= tEvent.aaiLaser1OpeningClosingTransitions(1, 1);
		fFirstLaser1CloseTime	= tEvent.aaiLaser1OpeningClosingTransitions(1, 2);
		%
	else%
		%
		fFirstLaser1OpenTime	= 0;
		fFirstLaser1CloseTime	= 0;
		%
	end;%
	if( numel(tEvent.aaiLaser2OpeningClosingTransitions) > 0 )
		%
		fFirstLaser2OpenTime	= tEvent.aaiLaser2OpeningClosingTransitions(1, 1);
		fFirstLaser2CloseTime	= tEvent.aaiLaser2OpeningClosingTransitions(1, 2);
		%
	else%
		%
		fFirstLaser2OpenTime	= 0;
		fFirstLaser2CloseTime	= 0;
		%
	end;%
	%
	if( numel(tEvent.aaiDoorOpeningClosingTransitions) > 0 )
		%
		fLastDoorOpenTime		= tEvent.aaiDoorOpeningClosingTransitions(end, 1);
		fLastDoorCloseTime		= tEvent.aaiDoorOpeningClosingTransitions(end, 2);
		%
	else%
		%
		fLastDoorOpenTime		= 0;
		fLastDoorCloseTime		= 0;
		%
	end;%
	if( numel(tEvent.aaiLaser1OpeningClosingTransitions) > 0 )
		%
		fLastLaser1OpenTime	    = tEvent.aaiLaser1OpeningClosingTransitions(end, 1);
		fLastLaser1CloseTime	= tEvent.aaiLaser1OpeningClosingTransitions(end, 2);
		%
	else%
		%
		fLastLaser1OpenTime		= 0;
		fLastLaser1CloseTime	= 0;
		%
	end;%
	if( numel(tEvent.aaiLaser2OpeningClosingTransitions) > 0 )
		%
		fLastLaser2OpenTime	    = tEvent.aaiLaser2OpeningClosingTransitions(end, 1);
		fLastLaser2CloseTime	= tEvent.aaiLaser2OpeningClosingTransitions(end, 2);
		%
	else%
		%
		fLastLaser2OpenTime		= 0;
		fLastLaser2CloseTime	= 0;
		%
	end;%
	%
	%
	% how much time laser 1 and laser 2 remained open
	iLaser1OpeningTime		= 0;
	for iTransition = 1:size( tEvent.aaiLaser1OpeningClosingTransitions, 1 );
		%
		iLaser1OpeningTime = iLaser1OpeningTime								...
			+	tEvent.aaiLaser1OpeningClosingTransitions(iTransition, 2)	...
			-	tEvent.aaiLaser1OpeningClosingTransitions(iTransition, 1);
		%
	end;%
	%
	iLaser2OpeningTime		= 0;
	for iTransition = 1:size( tEvent.aaiLaser2OpeningClosingTransitions, 1 );
		%
		iLaser2OpeningTime = iLaser2OpeningTime								...
			+	tEvent.aaiLaser2OpeningClosingTransitions(iTransition, 2)	...
			-	tEvent.aaiLaser2OpeningClosingTransitions(iTransition, 1);
		%
	end;%
	%
	%
	% compute the features
	tEvent.afFeatures =										...
		[	fFirstLaser1OpenTime  - fFirstDoorOpenTime,		...
			fFirstLaser2OpenTime  - fFirstDoorOpenTime,		...
			fFirstDoorCloseTime   - fFirstDoorOpenTime,		...    
			fFirstLaser1CloseTime - fFirstDoorOpenTime,		...
			fFirstLaser2CloseTime - fFirstDoorOpenTime,		...
			fLastDoorOpenTime     - fFirstDoorOpenTime,     ...
			fLastLaser1OpenTime   - fFirstDoorOpenTime,		...
			fLastLaser2OpenTime   - fFirstDoorOpenTime,		...
			fLastDoorCloseTime    - fFirstDoorOpenTime,		...
			fLastLaser1CloseTime  - fFirstDoorOpenTime,		...
			fLastLaser2CloseTime  - fFirstDoorOpenTime		... 
			iLaser1OpeningTime,								...
			iLaser2OpeningTime								];
	%
end % function

